package com.yuan.weike.service.impl;

import com.yuan.weike.mapper.TaskAcceptMapper;
import com.yuan.weike.model.TaskAccept;
import com.yuan.weike.service.TaskAcceptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TaskAcceptServiceImpl implements TaskAcceptService {

    @Autowired
    private TaskAcceptMapper taskAcceptMapper;

    @Override
    public TaskAccept addTaskAccept(TaskAccept taskAccept) {
        taskAccept.setCreatedTime(new Date());
        taskAccept.setUpdatedTime(new Date());
        taskAcceptMapper.insert(taskAccept);
        return taskAccept;
    }

    @Override
    public TaskAccept getTaskAcceptById(Long acceptId) {
        return taskAcceptMapper.selectById(acceptId);
    }

    @Override
    public TaskAccept getTaskAcceptByTaskIdAndWitkeyId(Long taskId, Long witkeyId) {
        return taskAcceptMapper.selectByTaskIdAndWitkeyId(taskId, witkeyId);
    }

    @Override
    public List<TaskAccept> getTaskAcceptsByWitkeyId(Long witkeyId) {
        return taskAcceptMapper.selectByWitkeyId(witkeyId);
    }

    @Override
    public TaskAccept updateTaskAccept(TaskAccept taskAccept) {
        taskAccept.setUpdatedTime(new Date());
        taskAcceptMapper.update(taskAccept);
        return taskAccept;
    }

    @Override
    public boolean deleteTaskAccept(Long acceptId) {
        return taskAcceptMapper.deleteById(acceptId) > 0;
    }
}